package com.by.yz.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

import com.by.yz.R;
import com.by.yz.mypersonal.PersonalContractActivity;
import com.by.yz.mypersonal.PersonalContractChatActivity;
import com.by.yz.mypersonal.PersonalContractSetActivity;

public class ContractMain extends TabActivity {
    /** Called when the activity is first created. */
    private TabHost tabHost;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.contract);

        tabHost=this.getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        intent=new Intent().setClass(this, PersonalContractChatActivity.class);
        spec=tabHost.newTabSpec("会话").setIndicator("会话").setContent(intent);
        tabHost.addTab(spec);
        intent=new Intent().setClass(this,  PersonalContractActivity.class);
        spec=tabHost.newTabSpec("联系人").setIndicator("联系人").setContent(intent);
        tabHost.addTab(spec);
        intent=new Intent().setClass(this,  PersonalContractSetActivity.class);
        spec=tabHost.newTabSpec("设置").setIndicator("设置").setContent(intent);
        tabHost.addTab(spec);
        //0-2共3个选项，默认选中选项1
        tabHost.setCurrentTab(1);

        RadioGroup radioGroup=(RadioGroup) this.findViewById(R.id.main_tab_group);
        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.main_tab_myExam:
                        tabHost.setCurrentTabByTag("会话");
                        break;
                    case R.id.main_tab_message:
                        tabHost.setCurrentTabByTag("联系人");
                        break;
                    case R.id.main_tab_settings:
                        tabHost.setCurrentTabByTag("设置");
                        break;
                    default:
                        //tabHost.setCurrentTabByTag("联系人");
                        break;
                }
            }
        });
    }
}
